package engine.newUi
{
	import engine.tip.TipsMainLogic;
	
	import flash.events.MouseEvent;
	
	import newx.com.config.StaticIni;
	import newx.com.control.window.NxWindowEvent;

	public class LuckyPrizeListLogic
	{
		private static var _self : LuckyPrizeListLogic;
		private var _ui : LuckyPrizeListUI;
		
		public function LuckyPrizeListLogic()
		{
		}
		
		public function Init():void
		{	
			ui.OKBtn.label = StaticIni.getSwfLangStr("AlertEx_16");
		}
		
		public function upDataList(listData:String,count:int):void
		{
			if(count <= 7 )
			{
				ui.windowBG.height = 150;
				ui.OKBtn.y = 105;
			}
			else if(count <= 15 )
			{
				ui.windowBG.height = 190;
				ui.OKBtn.y = 145;
			}
			else if(count <= 20 )
			{
				ui.windowBG.height = 220;
				ui.OKBtn.y = 165;
			}
			ui.List.htmlText = listData;
		}
		
		private function onOKbtn(event : MouseEvent):void
		{
			ui.showOrHide();
		}
		
		private function onCloseWindow(event:NxWindowEvent):void
		{
			ui.showOrHide();
		}
		
		private function blackfun(val:String):void
		{
			TipsMainLogic.instance.showMain(val);
		}
		private function hideTips(event:MouseEvent):void
		{
			TipsMainLogic.instance.hide();
		}
		
		public function BeforeShow():void
		{
			ui.windowBG.addEventListener(NxWindowEvent.WINDOW_CLOSE,onCloseWindow);
			ui.OKBtn.addEventListener(MouseEvent.CLICK,onOKbtn);
			ui.List.addLinkClickHandel(blackfun);
			ui.List.addEventListener(MouseEvent.MOUSE_OUT,hideTips);
			ui.List.addEventListener(MouseEvent.MOUSE_MOVE,hideTips);
				
		}
		
		public function AfterHide():void
		{
			ui.windowBG.removeEventListener(NxWindowEvent.WINDOW_CLOSE,onCloseWindow);
			ui.OKBtn.removeEventListener(MouseEvent.CLICK,onOKbtn);
			ui.List.removeLinkClickHandel();
			ui.List.removeEventListener(MouseEvent.MOUSE_OUT,hideTips);
			ui.List.removeEventListener(MouseEvent.MOUSE_MOVE,hideTips);
		}
		
		public function get ui():LuckyPrizeListUI
		{
			if(!_ui)
			{
				_ui = new LuckyPrizeListUI;
			}
			return _ui;
		}
		
		
		public static function getInstance():LuckyPrizeListLogic
		{
			if(!_self)
			{
				_self = new LuckyPrizeListLogic;
			}
			return _self;
		}
	}
}